import React, { Component } from 'react';
import Search from './components/Search';
import List from './components/List'

class App extends Component {
    // 初始化
    // list 四种状态, welcome users loading err
    state = { 
        users:[],
        isWelcome: true,
        isLoading: false,
        err: '',
    };

    updateListState = (stateObj) => {
        this.setState(stateObj);
    }

    render() {
        const { users, isWelcome, isLoading, err } = this.state;
        
        return (
            <div className="container">
                <Search updateListState={this.updateListState}/>
                {/* 通过...传state的所有属性 */}
                <List {...this.state}/>
                </div>
        );
    }
}

export default App;